Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0
Rayder44

Inserting a variable into a function

Question

Hi all,
 
I hope this hasn't been covered before. I also hope it's not something insanely simple... Hopefully I get my terminology right.
 
So I'm running apiece of code which sets the injection rate for a fusion reactor, the line reads:

component.reactor_logic_adapter.setInjectionRate()

The method expects a number to be used in the brackets, which is fine. But I want to run some other code and use a number stored in a variable. I'm running some code to work out what injection rate I need. Ideally I'd like to run something like this:

local a = 2
component.reactor_logic_adapter.setInjectionRate(a)

But of course that doesn't work haha. Is there a way I can insert a variable like that?

Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

The error I'm getting is this:

/test.lua:11: ')' expected near 'a'

The only thing I can think of is for whatever reason, the method can't retrieve a variable like that. Is there anything else I can do?

 

The mod I'm using is Mekanism, for reference.

 

EDIT: Oh I done goofed! I was referencing the same variable in the next line in a print function. Seems I stuffed up the formatting there!

 

Thanks for your help!

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.